package cn.itcast.scm.action;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.itcast.scm.entity.Page;
import cn.itcast.scm.entity.StoreHouse;
import cn.itcast.scm.service.StoreHouseService;

@Controller
@RequestMapping("/storeHouse")
public class StoreHouseAction extends BaseAction{
	@Resource
	private StoreHouseService storeHouseService;

    //	新增
	@RequestMapping(value="/insert")
	@ResponseBody //如果返回json格式，需要这个注解，这里用来测试环境
	public Object insert(StoreHouse storeHouse){
		System.out.println("---action.storeHouse:"+storeHouse);
		int i = 0;
		try {
			i = storeHouseService.insert(storeHouse);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return i;
	}
    //	删除
	@RequestMapping("/deleteList")
	@ResponseBody // 如果返回json格式，需要这个注解，这里用来测试环境
	public Object deleteList(String[] pks) {
		System.out.println("---doAjax.deleteList:" + pks);
		int i = 0;
		try {
			i = storeHouseService.deleteList(pks);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return i;
	}
	
	//根据主键修改供应商的信息
		@RequestMapping(value="/update")
		@ResponseBody //如果返回json格式，需要这个注解，这里用来测试环境
		public Object update(StoreHouse storeHouse){
			System.out.println("---action.update.storeHouse:"+storeHouse);
			int i = 0;
			try {
				i = storeHouseService.update(storeHouse);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			return i;
		}

		//通过关键字分页查询
		@RequestMapping("/selectPageUseDyc")
		@ResponseBody //如果返回json格式，需要这个注解，这里用来测试环境
		public Object selectPageUseDyc(Page<StoreHouse> page,StoreHouse storeHouse){
			
			page.setParamEntity(storeHouse);
			System.out.println("----page:"+page);

			Page p = storeHouseService.selectPageUseDyc(page);

			return p.getPageMap();
		}
}
